package study.itheima.mycookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/aaa/CookiePrac1")
public class CookiePrac1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //Cookie 的名称只能包含 ASCCI 码表中的字母、数字字符。不能包含逗号、分号、空格，不能以 $ 开头。
        //Cookie 的值不支持中文
        Cookie cookie = new Cookie("time", System.currentTimeMillis() + "");
        cookie.setMaxAge(3600);
        cookie.setPath("/");
        resp.addCookie(cookie);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
